package com.zksk.portal.controller.statistic;

import com.zksk.admin.api.RemoteAdminService;
import com.zksk.common.core.domain.R;
import com.zksk.common.core.web.controller.BaseController;
import com.zksk.common.log.annotation.Log;
import com.zksk.common.log.enums.BusinessType;
import com.zksk.portal.service.member.MemberService;
import com.zksk.portal.service.orders.OrdersService;
import com.zksk.portal.service.section.SectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 数据统计
 *
 * @author zksk
 */
@Slf4j
@RestController
@RequestMapping("/statistic")
@Api(tags = "数据统计相关接口")
public class StatisticController extends BaseController {

    @Autowired
    private SectionService sectionService;

    @Resource
    private RemoteAdminService remoteAdminService;

    @Autowired
    private OrdersService ordersService;

    @Autowired
    private MemberService memberService;

    @Log(title = "数据统计查询", businessType = BusinessType.SELECT)
    @ApiOperation(value = "获取数据统计信息")
    @GetMapping("/list")
    @ResponseBody
    public R<List> list(){
        List list=new ArrayList();
        //获取公告数量
        long countSection = sectionService.count();
        //获取入驻机构数量
        R<Long> longR = remoteAdminService.selectNums();
        //获取服务企业数量
        long countMember = memberService.count();
        //获取订单数量
        long countOrders = ordersService.count();

        list.add(countSection);
        list.add(longR.getData());
        list.add(countMember);
        list.add(countOrders);
        return R.ok(list);

    }

}
